


/*
// CSS添加缓存
var time = new Date().getTime();
document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"libs/css/themes.css?time="+time+"\"/>");
//document.write("<scr" + "ipt src='url.js?time="+time+"'></scr" + "ipt>");
console.log(time)
*/


//window.onresize = window.onload = window.onscroll = function(){
window.onload  = function(){ // window.onload

var iTime = new Date().getTime();

//菜单
$.ajax({
    type: "post",
    url: "libs/json/menu.json?t="+iTime,
    dataType: "json",
    success: function(data) {
        var navbar = document.getElementsByClassName('navbar-nav')[0];
        var navbarLi = navbar.getElementsByTagName('li');
        var navbarLiUlArr = new Array(); //创建子菜单ul空数组
        var childMenuArr = new Array(); //创建子菜单空数组
        var oMenu = data.result[0].content; //数据获取

        //添加一菜单
        for (var i = 0; i < oMenu.length; i++) {
           var oMenuHTML = "<li><a href=\""+oMenu[i].url+"\" target=\"_blank\">"+oMenu[i].zh+"</a></li>";
           if (oMenu[i].childMenu == undefined) {
            navbar.innerHTML += oMenuHTML;
           } else {
                var childMenuHtmlA =  "<li class=\"dropdown\"><a href=\"#\"class=\"dropdown-toggle\"data-toggle=\"dropdown\">"+oMenu[i].zh+"<span class=\"caret\"></span></a><ul class=\"dropdown-menu\"></ul></li>";
                navbar.innerHTML += childMenuHtmlA;
                var navbarLiUl = navbarLi[i].getElementsByTagName('ul')[0];//获取检索内容块
                navbarLiUlArr.unshift(navbarLiUl);
                childMenuArr.push(oMenu[i].childMenu);
                
           };
        };
        //console.log(navbarLiUlArr);
        //console.log(childMenuArr);


        //添加子菜单
        for (var n = 0; n < navbarLiUlArr.length; n++) {
            var navbarLiUl = document.getElementsByClassName('dropdown')[n].getElementsByTagName('ul')[0];//获取检索内容块
            for (var y = 0; y < childMenuArr[n].length; y++) {
                var childMenuHtmlB =  "<li><a href=\""+childMenuArr[n][y].url+" \"target=\"_blank\">"+childMenuArr[n][y].zh+"</a></li>";
                navbarLiUl.innerHTML += childMenuHtmlB;
            };
        };


        //添加 li class="active"
        var oUrl = window.document.location.href;  //获取当前页面完整 URL
        var navbarMenuLi = document.getElementsByClassName('navbar-nav')[0].getElementsByTagName('li');//获取元素
        //console.log(oUrl);
        for (var i = 0; i < navbarMenuLi.length; i++) {
            var navbarMenuLiA = navbarMenuLi[i].getElementsByTagName('a')[0];
            if (oUrl.indexOf(navbarMenuLiA.href) == 0) {        //查找合适的元素
                navbarMenuLi[i].setAttribute("class", "active");//设置元素class
            };
        };


    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert('菜单读取出错');
    }
});



/*
//Banner
$.ajax({
    type: "post",
    url: "libs/json/BannerLink.json?t="+iTime,
    dataType: "json",
    success: function(data) {
        var oCarouselInner = document.getElementsByClassName('carousel-inner')[0];
        var oCarouselInnerData = data.result[0].content; //数据获取
            console.log(oCarouselInnerData);
        for (var i = 0; i < oCarouselInnerData.length; i++) {
           var oCarouselInnerHtmlA = "<div class=\"item\"><a href=\"http://www.photophoto.cn/show/13299674.html\"target=\"_blank\"title=\"歼15数量多少架？编号全曝光\"><img src=\""+oCarouselInnerData[i].url+"\"alt=\"...\"></a><div class=\"carousel-caption\">...</div></div>";
           var oCarouselInnerHtmlB = "<div class=\"item\"><a href=\"http://www.photophoto.cn/show/13299674.html\"target=\"_blank\"title=\"歼15数量多少架？编号全曝光\"><img src=\""+oCarouselInnerData[i].url+"\"alt=\"...\"></a><div class=\"carousel-caption\">...</div></div>";
           if (i = 0) {
                oCarouselInner.innerHTML += oCarouselInnerHtmlA;
           } else {
                oCarouselInner.innerHTML += oCarouselInnerHtmlB;
           };
        };
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert('Banner-信息读取出错');
    }
});
*/



/*
//友情链接
$.ajax({
    type: "post",
    url: "libs/json/BannerLink.json?t="+iTime,
    dataType: "json",
    success: function(data) {
        var oBottomLink = document.getElementById('bottomLink');
        var oLinkData = data.result[1].content; //数据获取
        for (var i = 0; i < oLinkData.length; i++) {
           var oLinkHtml = "<li><a href=\""+oLinkData[i].url+"\" target=\"_blank\">"+oLinkData[i].title+"</a></li>";
           oBottomLink.innerHTML += oLinkHtml;
        };
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert('友情链接-信息读取出错');
    }
});
*/


    //banner
    var swiper = new Swiper('.swiper-container', {
        pagination: '.swiper-pagination',
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        paginationClickable: true,
        spaceBetween: 30,
        centeredSlides: true,
        autoHeight: true, //高度随内容变化
        loop : true,
        autoplay: 2500,
        autoplayDisableOnInteraction: false
    });




/***整站设置***/

//设置网页标题
document.getElementsByTagName('title')[0].innerHTML = '广州市迈图电子有限公司';

//设置LOGO连接
var logo = document.getElementsByClassName('logo')[0];
logo.href  = 'index.html';


//copyright内容
var copyrightP = document.getElementsByClassName('copyright')[0].getElementsByTagName('p')[0];
copyrightP.innerHTML  = 'COPYRIGHT &copy; 广州市迈图电子有限公司.2017 ALL RIGHTS RESERVED.';


/***整站设置 end***/



} // window.onload END



